/*
 *  Temperament12.h
 *  SoundController0002
 *
 *  Created by jiro on 10/10/02.
 *  Copyright 2010 jiro music. All rights reserved.
 *
 */

#pragma once

#include <string>
#include <cmath>
#include <iostream>

namespace sc
{

class Note { 
public:

	enum Id
	{
		Mute = -1,
		
		A = 0,

		ASharp = 1,
		BFlat = ASharp,

		B = 2,
		CFlat = B,

		C = 3,
		BSharp = C,

		CSharp = 4,
		DFlat = CSharp,
		
		D = 5,

		DSharp = 6,
		EFlat = DSharp,		
		
		E = 7,
		FFlat = E,

		F = 8,
		ESharp = F,

		FSharp = 9,
		GFlat = FSharp,

		G = 10,

		GSharp = 11,
		AFlat = GSharp,
		
		NoteCount = 12
	};

	enum MidiNumber
	{
		Mute_0 = -1,		//	this is not midi note, add this to availability
		C_minus1 = 0,
		BSharp_minus1 = 0,
		CSharp_minus1 = 1,
		DFlat_minus1 = 1,
		D_minus1 = 2,
		DSharp_minus1 = 3,
		EFlat_minus1 = 3,
		E_minus1 = 4,
		FFlat_minus1 = 4,
		F_minus1 = 5,
		ESharp_minus1 = 5,
		FSharp_minus1 = 6,
		GFlat_minus1 = 6,
		G_minus1 = 7,
		GSharp_minus1 = 8,
		AFlat_minus1 = 8,
		A_minus1 = 9,
		ASharp_minus1 = 10,
		BFlat_minus1 = 10,
		B_minus1 = 11,
		CFlat_minus1 = 11,
		C_0 = 12,
		BSharp_0 = 12,
		CSharp_0 = 13,
		DFlat_0 = 13,
		D_0 = 14,
		DSharp_0 = 15,
		EFlat_0 = 15,
		E_0 = 16,
		FFlat_0 = 16,
		F_0 = 17,
		ESharp_0 = 17,
		FSharp_0 = 18,
		GFlat_0 = 18,
		G_0 = 19,
		GSharp_0 = 20,
		AFlat_0 = 20,
		A_0 = 21,
		ASharp_0 = 22,
		BFlat_0 = 22,
		B_0 = 23,
		CFlat_0 = 23,
		C_1 = 24,
		BSharp_1 = 24,
		CSharp_1 = 25,
		DFlat_1 = 25,
		D_1 = 26,
		DSharp_1 = 27,
		EFlat_1 = 27,
		E_1 = 28,
		FFlat_1 = 28,
		F_1 = 29,
		ESharp_1 = 29,
		FSharp_1 = 30,
		GFlat_1 = 30,
		G_1 = 31,
		GSharp_1 = 32,
		AFlat_1 = 32,
		A_1 = 33,
		ASharp_1 = 34,
		BFlat_1 = 34,
		B_1 = 35,
		CFlat_1 = 35,
		C_2 = 36,
		BSharp_2 = 36,
		CSharp_2 = 37,
		DFlat_2 = 37,
		D_2 = 38,
		DSharp_2 = 39,
		EFlat_2 = 39,
		E_2 = 40,
		FFlat_2 = 40,
		F_2 = 41,
		ESharp_2 = 41,
		FSharp_2 = 42,
		GFlat_2 = 42,
		G_2 = 43,
		GSharp_2 = 44,
		AFlat_2 = 44,
		A_2 = 45,
		ASharp_2 = 46,
		BFlat_2 = 46,
		B_2 = 47,
		CFlat_2 = 47,
		C_3 = 48,
		BSharp_3 = 48,
		CSharp_3 = 49,
		DFlat_3 = 49,
		D_3 = 50,
		DSharp_3 = 51,
		EFlat_3 = 51,
		E_3 = 52,
		FFlat_3 = 52,
		F_3 = 53,
		ESharp_3 = 53,
		FSharp_3 = 54,
		GFlat_3 = 54,
		G_3 = 55,
		GSharp_3 = 56,
		AFlat_3 = 56,
		A_3 = 57,
		ASharp_3 = 58,
		BFlat_3 = 58,
		B_3 = 59,
		CFlat_3 = 59,
		C_4 = 60,
		BSharp_4 = 60,
		CSharp_4 = 61,
		DFlat_4 = 61,
		D_4 = 62,
		DSharp_4 = 63,
		EFlat_4 = 63,
		E_4 = 64,
		FFlat_4 = 64,
		F_4 = 65,
		ESharp_4 = 65,
		FSharp_4 = 66,
		GFlat_4 = 66,
		G_4 = 67,
		GSharp_4 = 68,
		AFlat_4 = 68,
		A_4 = 69,
		ASharp_4 = 70,
		BFlat_4 = 70,
		B_4 = 71,
		CFlat_4 = 71,
		C_5 = 72,
		BSharp_5 = 72,
		CSharp_5 = 73,
		DFlat_5 = 73,
		D_5 = 74,
		DSharp_5 = 75,
		EFlat_5 = 75,
		E_5 = 76,
		FFlat_5 = 76,
		F_5 = 77,
		ESharp_5 = 77,
		FSharp_5 = 78,
		GFlat_5 = 78,
		G_5 = 79,
		GSharp_5 = 80,
		AFlat_5 = 80,
		A_5 = 81,
		ASharp_5 = 82,
		BFlat_5 = 82,
		B_5 = 83,
		CFlat_5 = 83,
		C_6 = 84,
		BSharp_6 = 84,
		CSharp_6 = 85,
		DFlat_6 = 85,
		D_6 = 86,
		DSharp_6 = 87,
		EFlat_6 = 87,
		E_6 = 88,
		FFlat_6 = 88,
		F_6 = 89,
		ESharp_6 = 89,
		FSharp_6 = 90,
		GFlat_6 = 90,
		G_6 = 91,
		GSharp_6 = 92,
		AFlat_6 = 92,
		A_6 = 93,
		ASharp_6 = 94,
		BFlat_6 = 94,
		B_6 = 95,
		CFlat_6 = 95,
		C_7 = 96,
		BSharp_7 = 96,
		CSharp_7 = 97,
		DFlat_7 = 97,
		D_7 = 98,
		DSharp_7 = 99,
		EFlat_7 = 99,
		E_7 = 100,
		FFlat_7 = 100,
		F_7 = 101,
		ESharp_7 = 101,
		FSharp_7 = 102,
		GFlat_7 = 102,
		G_7 = 103,
		GSharp_7 = 104,
		AFlat_7 = 104,
		A_7 = 105,
		ASharp_7 = 106,
		BFlat_7 = 106,
		B_7 = 107,
		CFlat_7 = 107,
		C_8 = 108,
		BSharp_8 = 108,
		CSharp_8 = 109,
		DFlat_8 = 109,
		D_8 = 110,
		DSharp_8 = 111,
		EFlat_8 = 111,
		E_8 = 112,
		FFlat_8 = 112,
		F_8 = 113,
		ESharp_8 = 113,
		FSharp_8 = 114,
		GFlat_8 = 114,
		G_8 = 115,
		GSharp_8 = 116,
		AFlat_8 = 116,
		A_8 = 117,
		ASharp_8 = 118,
		BFlat_8 = 118,
		B_8 = 119,
		CFlat_8 = 119,
		C_9 = 120,
		BSharp_9 = 120,
		CSharp_9 = 121,
		DFlat_9 = 121,
		D_9 = 122,
		DSharp_9 = 123,
		EFlat_9 = 123,
		E_9 = 124,
		FFlat_9 = 124,
		F_9 = 125,
		ESharp_9 = 125,
		FSharp_9 = 126,
		GFlat_9 = 126,
		G_9 = 127,	
	};
	

	static const double pianississimo = 0.2 / 6.0;

	static const double pianissimo = 0.25 / 6.0;

	static const double piano = 0.5 / 6.0;

	static const double mezzoPiano = 0.75 / 6.0;

	static const double mezoForte = 1.0 / 6.0;
	
	static const double forte = 1.25 / 6.0;

	static const double fortissimo = 1.5 / 6.0;

	static const double fortississimo = 1.75 / 6.0;

	static Id GetNoteIdFrom( MidiNumber number )
	{
		if ( number == Mute_0 ) {
			return Mute;
		}
		return Id( static_cast< int >( number + 3 )% 12 ); 
	}
	
	static int GetOctaveFrom( MidiNumber number ) 
	{
		if ( number == Mute_0 ) {
			return 0;
		}
//		std::cout << static_cast< double >( number ) / 12.0 - 6.0 << std::endl;
		return std::floor( static_cast< double >( number + 3 ) / 12.0 - 6.0 );
	}
	
	static std::string ToString( MidiNumber number )
	{
		return "";
	}
	
	static std::string ToString( Id noteId ) 
	{
		return "";
	}
};

}